package com.itheima.reggie.controller;

import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Dish;
import com.itheima.reggie.domain.Setmeal;
import com.itheima.reggie.domain.SetmealDish;
import com.itheima.reggie.mapper.SetmealMapper;
import com.itheima.reggie.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class SetmealController {
    @Autowired
    private SetmealService setmealService;
    //套餐展示
    @GetMapping("/setmeal/list")
    @Cacheable(value = "setmeal",key = "#categoryId")
    public ResultInfo findList(Long categoryId,@RequestParam(defaultValue = "1") Integer status){
       List<Setmeal> setmealList = setmealService.findList(categoryId,status);
        return ResultInfo.success(setmealList);
    }
    //点击套餐图片展示套餐展示所有菜品
    @GetMapping("setmeal/dish/{id}")
    public ResultInfo findMyDish(@PathVariable("id") Long id){
       List<SetmealDish> dishList= setmealService.findMyDish(id);
       return ResultInfo.success(dishList);
    }
}
